package com.kaiqingsun.io;

import java.io.FileInputStream;
import java.io.InputStream;

public class Demo5 {
    public static void main(String[] args) throws
            Exception{
        InputStream is = new FileInputStream("./hello.txt");
       byte[] buf = new byte[5];
        while (true){
            int n= is.read(buf);
            //n ==0 Z只是代表本次没数据，以后可能还有v
            //n==-1 以后也没数据
            if (n== -1){
                //所有数据被读完了
                break;
            }
            for (int i = 0; i < n; i++) {
                byte b = buf[i];
                System.out.printf("02x\n",b);
            }
        }
        is.close();
    }
}
